package com.shievy.anweb

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import com.shievy.anweb.base.helper.LoaderServiceHelper
import com.shievy.anweb.databinding.ActivityMainBinding
import com.shievy.anweb.common.service.WebViewService

class MainActivity : AppCompatActivity() {
    val binding: ActivityMainBinding by lazy {
        DataBindingUtil.setContentView(
            this,
            R.layout.activity_main
        )
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding.tvMain.setOnClickListener {
//            ServiceLoader.load(TestService::class.java).iterator().next().openPage(this@MainActivity,Bundle().apply {
//                putString("tips",binding.tvMain.text.toString())
//            })
//            LoaderServiceHelper.load(WebViewService::class.java)
//                ?.openActivityPage(this@MainActivity, "https://www.baidu.com/", "百度", false)
            LoaderServiceHelper.load(WebViewService::class.java)
                ?.loadAssetsFile(this@MainActivity, "test/Demo.html", "", true)
//            LoaderServiceHelper.load(WebViewService::class.java)?.openPage(this@MainActivity)
//            LoaderServiceHelper.load(TestService::class.java)?.openPage(this@MainActivity)
//            ServiceLoader.load(WebViewService::class.java).iterator().next().openPage(this@MainActivity)
        }

    }
}